package jp.heartdokyun.model.component;

import android.os.Handler;



public class BehaviorE extends Behavior {
	Boolean run = true;
	Handler thandler;
	public BehaviorE(int speed, int angleSpeed, int distance,int initx, int inity) {

		super(speed, angleSpeed, distance, initx,  inity);
	}

	@Override
	protected void _init() {
		this.setInitX((int)Math.random() * 200);

		/*
		Timer timer;
		timer = new Timer(true);
		thandler = new Handler();
		timer.schedule(new TimerTask() {
			public void run() {
				// 表示の更新
				thandler.post(new Runnable() {
					public void run() {
						run = true;
						Log.d("timer","timer on");

					}
				});
			}
		}, 	1000,1000);
		*/
		
	}
	@Override
	public void caliculateNextPosition(int currentX, int currentY, int width, int height, int bitmapWidth, int bitmapHeight) {

		if(this.run)
		{
			this.setNextY(currentY + this.getSpeed());
			this.setNextX(currentX);
		}
			if (this.isOutOfFrameHeight(currentY, height + bitmapHeight, bitmapHeight)) {
				//this.setAvail(false);
				this.run = false;
			//	Log.d("timer", "out of");

			}
			if (this.isOutOfFrameHeight(currentY, height, bitmapHeight)) {
				this.setAvail(false);
				this.setNextX((int) (Math.random() * width));
				//this.setNextY(0);
				//Log.d("timer", "gold retunr");
			}
		
		
	}
}